package app.domain.order;

import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;



public class OrderQueue {
	
	private ConcurrentLinkedQueue<Order> orderQueue = new ConcurrentLinkedQueue<>();
		
	public synchronized boolean add(Order order) {
		orderQueue.add(order);
		notify();
		return true;
	}
	
	public synchronized Order remove() {
		while(orderQueue.isEmpty()) {
			try {
				wait();
			} catch (InterruptedException e) {}
		}
		return orderQueue.remove();
	}
}
